/***********************************************************************
 * @file:     xxx.c
 * @author:   guangjieMVP
 * @github:   https://github.com/guangjieMVP
 * @version:  v1.0.0
 * @date:     2020-xx-xx
 * @brief:               
*************************************************************************/
#ifndef _ABSTRACT_STACK_H_
#define _ABSTRACT_STACK_H_

#include "string.h"

/* 定义抽象栈 */
typedef struct _abstract_stack{
    int (*push)(struct _abstract_stack *abs, int val);            //出栈方法 
    int (*pop)(struct _abstract_stack *abs, int *val);            //入栈方法
}abstract_stack_t;

static inline int abstract_stack_init(abstract_stack_t *abs, 
                                     int (*push)(struct _abstract_stack *abs, int val), 
                                     int (*pop)(struct _abstract_stack *abs, int *val))
{
    if(!abs || !push || !pop)
        return -1;
    
    abs->push = push;
    abs->pop  = pop;
    return 0;
}

static inline int abstract_stack_deinit(abstract_stack_t *abs)
{
    if(!abs)
        return -1;

    abs->push = NULL;
    abs->pop  = NULL;
    return 0;
}

#endif